export default {
  data() {
    return {
      // 快捷选项配置
      pickerOptions: {
        shortcuts: [
          {
            text: '昨日',
            onClick(picker) {
              const end = new Date()
              end.setDate(end.getDate() - 1)
              const start = new Date(end)
              picker.$emit('pick', [start, end])
            }
          },
          {
            text: '最近3天',
            onClick(picker) {
              const end = new Date()
              const start = new Date()
              start.setDate(end.getDate() - 2)
              picker.$emit('pick', [start, end])
            }
          },
          {
            text: '最近7天',
            onClick(picker) {
              const end = new Date()
              const start = new Date()
              start.setDate(end.getDate() - 6)
              picker.$emit('pick', [start, end])
            }
          },
          {
            text: '最近14天',
            onClick(picker) {
              const end = new Date()
              const start = new Date()
              start.setDate(end.getDate() - 13)
              picker.$emit('pick', [start, end])
            }
          },
          {
            text: '最近30天',
            onClick(picker) {
              const end = new Date()
              const start = new Date()
              start.setDate(end.getDate() - 29)
              picker.$emit('pick', [start, end])
            }
          },
          {
            text: '本月',
            onClick(picker) {
              const start = new Date()
              start.setDate(1)
              const end = new Date()
              picker.$emit('pick', [start, end])
            }
          },
          {
            text: '上月',
            onClick(picker) {
              const start = new Date()
              start.setMonth(start.getMonth() - 1, 1)
              const end = new Date(start.getFullYear(), start.getMonth() + 1, 0)
              picker.$emit('pick', [start, end])
            }
          },
          {
            text: '最近60天',
            onClick(picker) {
              const end = new Date()
              const start = new Date()
              start.setDate(end.getDate() - 59)
              start.setHours(0, 0, 0, 0)
              end.setHours(23, 59, 59, 999)
              picker.$emit('pick', [start, end])
            }
          },
          {
            text: '最近90天',
            onClick(picker) {
              const end = new Date()
              const start = new Date()
              start.setDate(end.getDate() - 89)
              start.setHours(0, 0, 0, 0)
              end.setHours(23, 59, 59, 999)
              picker.$emit('pick', [start, end])
            }
          },
          {
            text: '最近半年',
            onClick(picker) {
              const end = new Date()
              const start = new Date()
              start.setMonth(end.getMonth() - 6)
              start.setDate(1) // 从当月初开始
              start.setHours(0, 0, 0, 0)
              end.setHours(23, 59, 59, 999)
              picker.$emit('pick', [start, end])
            }
          },
          {
            text: '最近一年',
            onClick(picker) {
              const end = new Date()
              const start = new Date()
              start.setFullYear(end.getFullYear() - 1)
              start.setMonth(end.getMonth())
              start.setDate(end.getDate() + 1) // 避免闰年问题
              start.setHours(0, 0, 0, 0)
              end.setHours(23, 59, 59, 999)
              picker.$emit('pick', [start, end])
            }
          }
        ]
      }
    }
  }
}
